package geometrie;

/**
 * Class of unit testing for the package geometrie
 * 
 */
public class TestGeometrie {
	public static void main(String[] args) {
		Transformation t;
		// ------------------ testRotation ------------
		// rotation x, 30º k
		t = Transformation.rotation(new Point(1, 0, 0), Math.PI / 6);
		print(t.getMatrix());
		// rotation y, 30º k
		t = Transformation.rotation(new Point(0, 1, 0), Math.PI / 6);
		print(t.getMatrix());
		// rotation z, 30º k
		t = Transformation.rotation(new Point(0, 0, 1), Math.PI / 6);
		print(t.getMatrix());

		// rotation 360k
		t = Transformation.rotation(new Point(0, 0, 1), Math.PI * 2);
		print(t.getMatrix());

		// rotation 0k
		t = Transformation.rotation(new Point(1, 1, 1), 0);
		print(t.getMatrix());

		// -------------------- testTranslation ------------------

		t = Transformation.translation(-30, 0, 0); // k
		print(t.getMatrix());

		t = Transformation.translation(0, -30, 0); // k
		print(t.getMatrix());

		t = Transformation.translation(0, 0, -30);// k
		print(t.getMatrix());

		t = Transformation.translation(-30, -30, -30);// k
		print(t.getMatrix());

		// --------------- testIdentite -----------
		t = Transformation.identite();// k
		print(t.getMatrix());

		// -------------- testCompose ------------
		Transformation t1 = Transformation.translation(0, 0, -30);
		Transformation t2 = Transformation.rotation(new Point(1, 0, 0),
				Math.PI / 6);
		t = Transformation.compose(t1, t2);// k
		print(t.getMatrix());

		t = Transformation.compose(t2, t1); // ks
		print(t.getMatrix());

		// --- testPoint ---- k
		Point p = new Point(1, 1, 1);
		System.out.println(p);
		p.applyTransformation(t1);
		System.out.println(p);

		p = new Point(1, 1, 1);
		System.out.println(p);
		p.applyTransformation(t2);
		System.out.println(p);
	}

	private static void print(double[][] matrix) {
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {
				System.out.print(matrix[i][j] + " ");
			}
			System.out.println();
		}
		System.out.println();
	}
}
